<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Jialeo\LaravelSchemaExtend\Schema;

class CreateFsCompanyRoleMappingsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('fs_company_role_mappings', function (Blueprint $table) {
            $table->id();

            $table->unsignedInteger('fsCompanyUserMappingId')->default(0)->comment('公司用户关联ID; 复审=0');
            $table->unsignedInteger('fsCompanyId')->default(0)->comment('公司ID');
            $table->unsignedInteger('rmsUserId')->default(0)->comment('用户ID');
            $table->unsignedTinyInteger('roleId')->default(0)->comment('角色ID 1初审 2复审');


            $table->unsignedInteger('createdAt')->default(0)->comment('创建时间');
            $table->unsignedInteger('createdByUid')->default(0)->comment('创建人');
            $table->unsignedInteger('updatedAt')->default(0)->comment('修改时间');
            $table->unsignedInteger('updatedByUid')->default(0)->comment('修改人');
            $table->tinyInteger('isDeleted')->default(0);
            $table->collation = 'utf8mb4_general_ci';
            $table->comment = '稽核 - 供应商用户职位关联';

            $table->index('fsCompanyUserMappingId', 'idx_fs_company_user_mapping_id');
            $table->index(['fsCompanyId', 'roleId', 'rmsUserId'], 'idx_fsCompanyUser');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('fs_company_role_mappings');
    }
}
